import  numpy as np
def sigmoid(x):
    return (1/(1+np.exp(-x)))
def dsigmoid(y):
    return  y*(1-y)
x=np.array([[0,0,1],
           [0,1,1],
           [1,0,1],
           [1,1,1]])
y=np.array([0,1,0,1]).T
w0=np.random.random((3,4))
print(w0)
b0=0.5
lrate=0.3
for epochs in range(20):
    inx=x
    outy=sigmoid(np.dot(inx,w0)+b0)
    w0+=lrate*np.dot(inx.T,2*(y-outy)*dsigmoid(outy))
    b0+=lrate*2*(y-outy)*dsigmoid(outy)
    err=(y-outy)*(y-outy)
    print("epochs=",epochs+1,"error is",err.T)
